<template>
	<view class="container">
		<tui-loading v-show="!pageData.loading"></tui-loading>
		<view class="page" v-show="pageData.loading" :style="{ 'marginTop': header.init.height + 'px' }">
			<tui-navigation-bar @init="initNavigation" @change="changeNavigation" :title="header.title"
				:color="tui.getColorSite().title.color" :backgroundColor="tui.getColorSite().title.backgroundColor"
				:splitLine="header.splitLine" :isOpacity="header.isOpacity" :maxOpacity="header.maxOpacity"
				:transparent="header.transparent" :scrollTop="header.scrollTop" :scrollRatio="header.scrollRatio"
				:isCustom="header.isCustom" :isImmersive="header.isImmersive" :isFixed="header.isFixed"
				:backdropFilter="header.backdropFilter" :dropDownHide="header.dropDownHide" :zIndex="header.zIndex">
				<view class="tui-header-icon" :style="{ top: header.init.top + 'px' }"
					v-if="!tui.inArray(get.tpl,['authList'])">
					<tui-icon name="arrowleft" :color="tui.getColorSite().title.color" @click="back"></tui-icon>
				</view>
			</tui-navigation-bar>
			<u-sticky bgColor="#fff" v-if="tui.inArray(get.tpl,['wallet'])">
				<view class="tui-mybg-box" style="height: 464rpx;" v-if="tui.inArray(get.tpl,['wallet'])">
					<image :src="pageData.background_img" class="tui-my-bg-h-464" mode="widthFix"></image>
					<view class="tui-header-center">
						<view class="tui-wallet">
							<view class="tui-wallet-info">
								<view class="tui-wallet-info-title">当前{{get.title}}余额</view>
								<view class="tui-wallet-info-value" v-if="user.userInfo">
									{{user.userInfo[get.key]}}
								</view>
							</view>
							<view class="button-action" v-if="user.userInfo && user.userInfo[get.key] > 0">
								<tui-tag type="white" size="35rpx" plain shape="square"
									@click="detail('publicForm', {title:get.title+'转增',tpl:'userWalletGive',key:get.key})"
									v-if="tui.inArray(get.key,['u_species'])">转赠</tui-tag>
								<tui-tag type="white" size="35rpx" plain shape="square"
									@click="detail('publicForm', {title:get.title+'提现',tpl:'userWalletWithdrawal',key:get.key})"
									v-if="tui.inArray(get.key,['commission'])">提现</tui-tag>
								<tui-tag type="white" size="35rpx" plain shape="square"
									@click="detail('publicForm', {title:get.title+'转换',key:get.key})"
									v-if="tui.inArray(get.key,['integral'])">转换</tui-tag>
							</view>
						</view>
					</view>
				</view>
				<u-tabs :list="pageData.tabs.data" :current="pageData.tabs.index" lineColor="#E41F19" :lineWidth="40"
					:activeStyle="{ color: '#E41F19' }" :scrollable="false" @click="tabsClick"></u-tabs>
			</u-sticky>
			<view :class="tui.inArray(get.tpl,['address','invoiceTitle'])?'list-add-button':''">
				<u-cell-group :title="item.title" v-for="(item, index) in listData.data" :key="index"
					v-if="listData.data.length>0&&tui.inArray(get.tpl,['invoiceTitle'])&&item.list.length>0">
					<u-cell v-for="(listItem, listIndex) in item.list" :key="listIndex"
						@click="detail('item', listItem)" :arrow="false">
						<view slot="title">
							<view class="flex-b"
								style="flex-direction: column;padding: 10rpx 0 10rpx 20rpx;align-items: flex-start;">
								<view>{{ listItem.title }}</view>
								<view v-if="tui.inArray(listItem.kj_type,[2])">{{ listItem.code }}</view>
							</view>
						</view>
						<view slot="right-icon">
							<view class="flex-c" style="width: 80rpx;" @click.stop="showModal('delete', listItem)">
								<u-icon name="trash-fill" size="25"></u-icon>
							</view>
						</view>
					</u-cell>
				</u-cell-group>
				<u-cell-group>
					<u-cell v-for="(item, index) in listData.data" :key="index" @click="detail('item', item)"
						:arrow="false" v-if="listData.data.length>0&&tui.inArray(get.tpl,['address'])">
						<view slot="title">
							<view class="flex-b">
								<view>{{ item.full_name }}</view>
								<view>{{ item.phone }}</view>
							</view>
							<view class="flex" style="margin-top: 10rpx;flex-direction: column;">
								<view style="margin-right: 10rpx;margin-bottom: 10rpx;" v-if="item.is_default === 1">
									<tui-tag type="danger" padding="6rpx" style="background-color: red;">默认</tui-tag>
								</view>
								<view>{{ item.province }}{{ item.city }}{{ item.district }}{{ item.info }}</view>
							</view>
						</view>
						<view slot="right-icon">
							<view class="flex-c" style="width: 80rpx;" @click.stop="showModal('delete', item)">
								<u-icon name="trash-fill" size="25"></u-icon>
							</view>
						</view>
					</u-cell>
					<u-cell v-for="(item, index) in listData.data" :key="index" @click="detail('info', item)"
						v-if="listData.data.length>0&&tui.inArray(get.tpl,['agreement'])">
						<view slot="title">
							<view>
								<tui-overflow-hidden :lineClamp="2">
									{{ item.title }}
								</tui-overflow-hidden>
							</view>
							<view class="flex-b" style="margin-top: 20rpx;">
								<view class="flex">
									<tui-icon :size="16" name="eye"></tui-icon>
									<view style="margin-left: 10rpx;">{{item.hits}}</view>
								</view>
								<view class="flex">
									<tui-icon :size="16" name="time"></tui-icon>
									<view style="margin-left: 10rpx;">{{item.create_time}}</view>
								</view>
							</view>
						</view>
					</u-cell>
					<u-cell isLink v-for="(item, index) in listData.data" :key="index"
						@click="detail(item.key, {title:item.title,tpl:item.tpl,})"
						v-if="listData.data.length>0&&tui.inArray(get.tpl,['setting'])">
						<view slot="title">
							<view class="flex-b">
								<view class="flex">
									<view>{{ item.title }}</view>
								</view>
							</view>
						</view>
					</u-cell>
					<view v-if="tui.inArray(get.tpl,['setting'])" style="padding:50rpx 120rpx;">
						<tui-button shadow shape="circle" :type="tui.getColorSite().button.type" height="65rpx"
							width="100%" @click="detail('loginOut')">退出登录</tui-button>
					</view>

					<u-cell :isLink="false" v-for="(item, index) in listData.data" :key="index"
						@click="detail('publicList', item)"
						v-if="listData.data.length>0&&tui.inArray(get.tpl,['team'])">
						<view slot="title">
							<view class="tanxing">
								<!-- <image :src="item.url"></image> -->
								<image class="touxiang" src="../static/logo.png"></image>
								<view>
									<view class="flex-b">
										<view class="tui-explain explainName">
											昵称：{{ item.nick_name||'未设置' }}[{{ item.real_name||'未设置' }}]
										</view>
									</view>
									<view class="flex-b">
										<view class="tui-explain explainTime">
											注册时间：{{item.create_time}}
										</view>
									</view>
								</view>
							</view>
							<!-- <u-line></u-line> -->
							<view class="flex-b">
								<view class="tui-explain explainPhone">
									手机号：&nbsp;{{ item.tel_string }}
								</view>
								<view class="tui-explain explainYeji">
									<view class="flex">
										<view>团队业绩：</view>
										<view class="tui-red">￥{{ item.team_achievement }}</view>
									</view>
								</view>
							</view>
						</view>

					</u-cell>
					<u-cell v-for="(item, index) in listData.data" :key="index" @click="detail('info', item)"
						v-if="listData.data.length>0&&tui.inArray(get.tpl,['recharge'])">
						<view slot="title">
							<view class="flex-b">
								<view class="flex" style="flex-direction: column;">
									<view>操作用户：{{ item.form_username }}</view>
									<view>充值用户：{{ item.to_username }}</view>
									<view>充值数量：<text class="tui-red">{{ item.price }}</text></view>
									<view>操作时间：{{ item.create_time }}</view>
								</view>
								<view class="flex">
									<tui-tag type="danger" :scaleMultiple="scaleMultiple">成功</tui-tag>
								</view>
							</view>
						</view>
					</u-cell>
					<u-cell v-for="(item, index) in listData.data" :key="index" @click="detail('info', item)"
						v-if="listData.data.length>0&&tui.inArray(get.tpl,['wallet'])">
						<view slot="title">
							<view class="flex-b">
								<view class="flex">
									<view>{{ item.info }}</view>
								</view>
								<view class="flex">
									<view class="tui-red"
										v-if="tui.inArray(item.type,[1,3,4,6,8,11,14,15,99,77,76,75])">+{{item.price}}
									</view>
									<view class="tui-green" v-else-if="tui.inArray(item.type,[2,7,9,10,12,13])">
										-{{item.price}}</view>
									<view class="tui-red" v-else>[{{item.type}}]{{item.price}}</view>
								</view>
							</view>
							<view class="flex-b" style="margin-top: 20rpx;">
								<view class="flex">
									<view class="tui-gray">{{item.create_time}}</view>
								</view>
								<view class="flex">
									<view class="tui-red" v-if="tui.inArray(item.type,[7])&&item.status === 0">待审核
									</view>
									<view class="tui-gray" v-else>成功</view>
								</view>
							</view>
						</view>
					</u-cell>
					<u-cell v-for="(item, index) in listData.data" :key="index"
						v-if="listData.data.length>0&&tui.inArray(get.tpl,['wxAppletMessageSubscriber'])">
						<view slot="title">
							<view>
								<tui-overflow-hidden :lineClamp="2">
									{{ item.title }}
								</tui-overflow-hidden>
							</view>
						</view>
						<view slot="right-icon">
							<view class="flex-c" style="width: 180rpx;">
								<tui-tag type="green" padding="10rpx 12rpx" v-if="tui.inArray(item.status, [0])"
									@click="detail('subscriber',item)">订阅通知</tui-tag>
								<tui-tag type="pink" padding="10rpx 12rpx" v-else
									@click="detail('subscriber',item)">订阅成功</tui-tag>
							</view>
						</view>
					</u-cell>
				</u-cell-group>
				<!-- 新增地址 -->
				<view class="tui-list-button" v-if="tui.inArray(get.tpl,['address'])">
					<tui-button shadow shape="circle" :type="tui.getColorSite().button.type" height="88rpx"
						@click="detail('add')">+新增收货地址</tui-button>
				</view>
				<!-- 新增地址 -->
				<view class="tui-list-button" v-if="tui.inArray(get.tpl,['invoiceTitle'])">
					<tui-button shadow shape="circle" :type="tui.getColorSite().button.type" height="88rpx"
						@click="detail('add')">+新增发票抬头</tui-button>
				</view>
				<view class="tui-list-button" v-if="tui.inArray(get.tpl,['recharge'])">
					<tui-button shadow shape="circle" :type="tui.getColorSite().button.type" height="88rpx"
						@click="detail('add')">+充值</tui-button>
				</view>

				<view v-if="!tui.inArray(get.tpl,['invoiceTitle','setting'])">
					<tui-loadmore :index="3" :type="tui.getColorSite().loadmore.type"
						v-if="listData.xhr.status && listData.status" :text="listData.xhr.text"></tui-loadmore>
					<tui-divider width="60%" :dividerColor="tui.getColorSite().divider.dividerColor"
						:color="tui.getColorSite().divider.color"
						v-if="!listData.xhr.status && listData.status">{{ listData.xhr.text }}</tui-divider>
				</view>
			</view>
			<view class="tui-safearea-bottom"></view>
			<tui-modal :show="modalSite.status" :content="modalSite.content" shape="circle" :button="modalSite.button"
				@click="clickModal"></tui-modal>
			<tui-actionsheet :zIndex="99999" :show="pageData.actionsheet.show" :itemList="pageData.actionsheet.itemList"
				:maskClosable="pageData.actionsheet.maskClosable" :tips="pageData.actionsheet.tips"
				:color="tui.getColorSite().actionsheet.color" :radius="pageData.actionsheet.radius"
				:isCancel="pageData.actionsheet.isCancel" zIndex="991024" @click="actionsheetClick"
				@cancel="actionsheetClose">
			</tui-actionsheet>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scaleMultiple: 0.7,
				get: {},
				header: {
					title: '', //NavigationBar标题
					splitLine: true, //是否需要分割线
					isOpacity: false, //是否设置不透明度
					maxOpacity: 1, //不透明度最大值 0-1
					transparent: false, //背景透明 （设置该属性，则背景透明，只出现内容，isOpacity和maxOpacity失效）
					scrollTop: 0, //滚动条滚动距离
					scrollRatio: 0.3, //isOpacity 为true时生效（opacity=scrollTop /windowWidth * scrollRatio）
					isCustom: false, //是否自定义NavigationBar内容
					isImmersive: true, //是否沉浸式,
					isFixed: true, //是否固定
					backdropFilter: false, //是否开启高斯模糊效果[仅在支持的浏览器有效果]，为true时maxOpacity设置小于1的值
					dropDownHide: false, //下拉隐藏NavigationBar，主要针对有回弹效果ios端
					zIndex: 9998, //z-index值
					init: {
						width: 0,
						height: 0,
						left: 0,
						top: 0,
						top: 0,
						scrollH: 0,
					},
				},
				pageData: {
					loading: false,
					background_img: '',
					tabs: {
						index: -1,
						data: []
					},
					actionsheet: {
						show: false,
						tips: "",
						itemList: [],
						maskClosable: true,
						radius: true,
						isCancel: true,
						type: '',
						param: {},
					},
				},
				xhrUrl: '',
				listData: {
					data: {},
					page: 0,
					length: 0,
					isMore: true,
					xhr: {
						url: '',
						status: true,
						text: '正在加载...',
					},
					status: true,
				},
				modalSite: {
					key: '',
					status: false,
					content: '确认删除地址吗？',
					data: {},
					button: [
						// 
						{
							text: '取消',
							type: 'gray'
						},
						{
							text: '确定',
							type: 'red'
						}
					],
				},
				appInit: {},
				user: {},
			}
		},
		// 监听页面加载，其参数为上个页面传递的数据，参数类型为 Object（用于页面传参）
		onLoad(e) {
			let that = this;
			// uni.startPullDownRefresh();
			uni.stopPullDownRefresh(); //停止当前页面下拉刷新
			if (typeof(e.scene) != 'undefined') {
				e = that.tui.getUrlkey(decodeURIComponent(e.scene));
			}
			that.get = e;
			if (typeof that.get.title !== 'undefined') {
				switch (that.get.tpl) {
					default:
						that.header.title = that.get.title;
						break;
				}
				if (that.header.title.length > 13) {
					that.header.title = that.header.title.slice(0, 13) + '...';
				}
				that.$forceUpdate();
			}
			console.log("self:getData=>", that.get);
			let obj = {};
			// #ifdef MP-WEIXIN
			obj = wx.getMenuButtonBoundingClientRect();
			// #endif
			// #ifdef MP-BAIDU
			obj = swan.getMenuButtonBoundingClientRect();
			// #endif
			// #ifdef MP-ALIPAY
			my.hideAddToDesktopMenu();
			// #endif
			uni.getSystemInfo({
				success: function(res) {
					that.header.init.width = obj.left || res.windowWidth;
					that.header.init.height = obj.top ? obj.top + obj.height + 8 : res.statusBarHeight + 44;
					that.header.init.top = obj.top ? obj.top + (obj.height - 32) / 2 : res.statusBarHeight + 6;
					that.header.init.scrollH = res.windowWidth * 0.6;
				}
			});
			that.$forceUpdate();
			switch (that.get.tpl) {
				case 'wxAppletMessageSubscriber':
					that.listData.xhr.url = '/wx/message/subscriber';
					that.initialize();
					break;
				case 'setting':
					that.initialize();
					break;
				default:
					break;
			}
		},
		// 监听页面显示。页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面
		onShow() {
			let that = this;
			// #ifdef MP-WEIXIN
			if (wx.hideHomeButton) {
				wx.hideHomeButton();
			}
			uni.$once('wxGetUserPhone', function(res) {
				console.log('监听到事件来自 wxGetUserPhone', res);
				that.userInfo = res.user;
				uni.$off('wxGetUserPhone')
			})
			// #endif
			switch (that.get.tpl) {
				case 'agreement':
					that.listData.xhr.url = '/agreement';
					that.initialize();
					break;
				case 'address':
					that.xhrUrl = '/user/address';
					that.listData.xhr.url = '/user/address';
					that.initialize();
					break;
				case 'invoiceTitle':
					that.xhrUrl = '/user/invoice/title';
					that.listData.xhr.url = '/user/invoice/title';
					that.initialize();
					break;
				case 'wallet':
					that.listData.xhr.url = '/user/wallet';
					that.initialize();
					break;
				case 'team':
					that.listData.xhr.url = '/user/team';
					that.initialize();
					break;
				case 'deliver_goods':
					that.listData.xhr.url = '/user/deliver/goods';
					that.initialize();
					break;
				case 'recharge':
					that.listData.xhr.url = '/user/wallet';
					that.initialize();
					break;
				default:
					if (that.pageData.loading === false) {
						that.initialize();
					}
					break;
			}
		},
		// 监听页面滚动，参数为Object
		onPageScroll(e) {
			let that = this;
			that.header.scrollTop = e.scrollTop;
		},
		methods: {
			initialize() {
				let that = this;
				let Int = setInterval(function() {
					that.user = that.tui.getCache("user");
					console.log('self:user=>', that.user);
					if (typeof(that.user) == 'object') {
						clearInterval(Int);
						that.__init();
					}
				}, 800);
			},
			async __init() {
				let that = this;
				that.appInit = that.tui.getCache("appInit");
				that.pageData.background_img = that.appInit.image.member_background_img;
				console.log('self:appInit=>', that.appInit);
				switch (that.get.tpl) {
					case 'wallet':
						switch (that.get.key) {
							case 'balance':
								that.pageData.tabs.data = [
									// 
									{
										value: -1,
										name: '全部',
									},
									{
										value: '1',
										name: '消费',
									},
									{
										value: '2',
										name: '充值',
									},
								];
								break;
							case 'integral':
								that.pageData.tabs.data = [
									// 
									{
										value: -1,
										name: '全部',
									},
									{
										value: '3,14,15',
										name: '释放',
									},
									{
										value: '4',
										name: '奖励',
									},
									{
										value: '12,13',
										name: '转换',
									},
									{
										value: '99',
										name: '分红',
									},
								];
								break;
							case 'commission':
								that.pageData.tabs.data = [
									// 
									{
										value: -1,
										name: '全部',
									},
									{
										value: '6',
										name: '转换',
									},
									{
										value: '7',
										name: '提现',
									}
								];
								break;
							case 'u_species':
								that.pageData.tabs.data = [
									// 
									{
										value: -1,
										name: '全部',
									},
									{
										value: '8',
										name: '转换',
									},
									{
										value: '9',
										name: '消费',
									},
									{
										value: '10,11',
										name: '转赠',
									},
								];
								break;
							default:
								break;
						}
						that.pageData.tabs.index = 0;
						break;
					default:
						break;
				}
				that.pageData.loading = true;
				that.$forceUpdate();
				switch (that.get.tpl) {
					case 'setting':
						that.listData.data = [
							// 
							{
								title: '收货地址',
								tpl: 'address',
								key: 'publicList',
							},
							{
								title: '操作密码',
								tpl: 'manage_password',
								key: 'publicForm',
							},
							{
								title: '登录密码',
								tpl: 'password',
								key: 'publicForm',
							},
						];
						break;
					default:
						that.listData.page = 0;
						that.$forceUpdate();
						that.initList();
						break;
				}
			},
			tabsClick(e) {
				let that = this;
				that.listData.xhr.text = '正在获取 ... ...';
				that.pageData.tabs.index = e.index;
				that.listData.page = 0;
				that.initList();
			},
			detail(key, item = {}) {
				let that = this;
				switch (that.get.tpl) {
					case 'address':
						let paramAddress = {};
						paramAddress.tpl = that.get.tpl;
						paramAddress.callback = 'def';
						paramAddress.address_id = item.id || 0;
						paramAddress.retreat = 1;
						switch (key) {
							case 'add':
								paramAddress.title = '新增地址';
								if (typeof(that.get.isSelect) != 'undefined') {
									//地址选择？
									paramAddress.retreat = 2;
									paramAddress.callback = 'cart';
								}
								that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramAddress));
								break;
							case 'item':
								if (typeof(that.get.isSelect) != 'undefined') {
									//地址选择？
									that.tui.setCache('lastUppAddressData', item);
									that.tui.urlBack(1);
								} else {
									paramAddress.title = '修改地址';
									that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramAddress));
								}
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'invoiceTitle':
						let paramInvoiceTitle = {};
						paramInvoiceTitle.callback = 'def';
						paramInvoiceTitle.invoice_title_id = item.id || 0;
						paramInvoiceTitle.retreat = 1;
						switch (key) {
							case 'add':
								paramInvoiceTitle.title = '新增抬头';
								if (typeof(that.get.isSelect) != 'undefined') {
									//选择？
									paramInvoiceTitle.retreat = 2;
									paramInvoiceTitle.callback = 'cart';
								}
								that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramInvoiceTitle));
								break;
							case 'item':
								if (typeof(that.get.isSelect) != 'undefined') {
									//选择？
									that.tui.setCache('lastUppInvoiceTitleData', item);
									that.tui.urlBack(1);
								} else {
									paramInvoiceTitle.title = '修改抬头';
									that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramInvoiceTitle));
								}
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'agreement':
						let paramAgreement = {};
						switch (key) {
							case 'info':
								paramAgreement.tpl = that.get.tpl;
								paramAgreement.id = item.id;
								paramAgreement.title = item.title;
								that.tui.urlHref('/pages/public-info?' + that.tui.initParamsData(paramAgreement));
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'wallet':
						let paramWallet = {};
						switch (key) {
							case 'publicForm':
								paramWallet.title = item.title;
								paramWallet.tpl = that.get.tpl;
								paramWallet.key = item.key;
								switch (item.key) {
									case "integral":
										console.log(paramWallet, item.key);
										that.pageData.actionsheet.tips = "选择转入类型";
										that.pageData.actionsheet.isCancel = true;
										that.pageData.actionsheet.type = 'convert';
										that.pageData.actionsheet.param = paramWallet;
										that.pageData.actionsheet.itemList = [
											// 
											{
												'text': "积分转入佣金",
												'to': 'commission',
											},
											{
												'text': "积分转入U币",
												'to': 'u_species',
											},
										];
										that.pageData.actionsheet.show = true;
										break;
									case "u_species":
									case "commission":
										that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramWallet));
										break;
									default:
										console.log(that.get.tpl, key, item, item.key);
										break;
								}
								break;
							case 'publicInfo':
								paramWallet.title = item.title;
								paramWallet.tpl = item.tpl;
								paramWallet.id = item.id;
								that.tui.urlHref('/pages/public-info?' + that.tui.initParamsData(paramWallet));
								break;
							case 'publicList':
								paramWallet.title = item.title;
								paramWallet.tpl = item.tpl;
								that.tui.urlHref('/pages/public-list?' + that.tui.initParamsData(paramWallet));
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'recharge':
						let paramRecharge = {};
						switch (key) {
							case 'add':
								paramRecharge.title = that.get.title;
								paramRecharge.tpl = that.get.tpl;
								paramRecharge.key = that.get.key;
								switch (that.get.key) {
									case "u_species":
										that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramRecharge));
										break;
									default:
										console.log(that.get.tpl, key, item, that.get.key);
										break;
								}
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'setting':
						let paramSetting = {};
						switch (key) {
							case 'publicForm':
								paramSetting.title = item.title;
								paramSetting.tpl = item.tpl;
								that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(paramSetting));
								break;
							case 'publicInfo':
								paramSetting.title = item.title;
								paramSetting.tpl = item.tpl;
								paramSetting.id = item.id;
								that.tui.urlHref('/pages/public-info?' + that.tui.initParamsData(paramSetting));
								break;
							case 'publicList':
								paramSetting.title = item.title;
								paramSetting.tpl = item.tpl;
								that.tui.urlHref('/pages/public-list?' + that.tui.initParamsData(paramSetting));
								break;
							case 'loginOut':
								that.tui.removeUserInfo(function() {
									that.tui.urlOpen('/pages/public-login');
								});
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'team':
						let paramTeam = {};
						switch (key) {
							case 'publicList':
								if (item.share[0].count > 0) {
									paramTeam.title = that.get.title;
									paramTeam.tpl = that.get.tpl;
									paramTeam.parent_id = item.id;
									paramTeam.timestamp = that.tui.formatDate().timestamp;
									that.tui.urlHref('/pages/public-list?' + that.tui.initParamsData(paramTeam));
								}
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					case 'wxAppletMessageSubscriber':
						switch (key) {
							case 'subscriber':
								// #ifdef H5
								that.tui.toast("请在微信客户端调试！", false, function() {}, 1500);
								// #endif
								// #ifdef MP-WEIXIN
								uni.getSetting({
									withSubscriptions: true, //是否获取用户订阅消息的订阅状态，默认false不返回
									success(res) {
										if (!res.subscriptionsSetting) {
											that.tui.toast("无法获取订阅消息对象，可能版本库兼容原因！", false, function() {}, 1500);
										} else if (!res.subscriptionsSetting.mainSwitch) {
											that.tui.toast("订阅消息未打开！", false, function() {}, 1500);
										} else {
											if (typeof res.subscriptionsSetting[item.tplId] != 'undefined') {
												let subscriptionsArr = [];
												for (let [key, value] of Object.entries(res.subscriptionsSetting
														.itemSettings)) {
													if (value === 'accept') {
														subscriptionsArr.push(key)
													}
												}
												if (subscriptionsArr.length > 0) {
													that.tui.post('/user/init', {
														wx_applet_data: {
															subscriptionsArr: subscriptionsArr,
														},
													}).then(function(res) {
														console.log(res);
														that.tui.setUserInfo(res.data, function(response) {
															console.log("缓存建立");
														});
													});
												}
											} else {
												uni.requestSubscribeMessage({
													tmplIds: [item.tplId],
													success: function(res) {
														console.log(res);
														item.status = 1;
													},
													fail: function() {},
												});
											}
										}
									}
								})
								// #endif
								break;
							default:
								console.log(that.get.tpl, key, item);
								break;
						}
						break;
					default:
						console.log(that.get.tpl, key, item);
						break;
				}
			},
			async actionsheetClick(e) {
				let that = this;
				switch (that.pageData.actionsheet.type) {
					case 'convert':
						that.pageData.actionsheet.param.title = e.text;
						that.pageData.actionsheet.param.to = e.to;
						that.tui.urlHref('/pages/public-form?' + that.tui.initParamsData(that.pageData.actionsheet
							.param));
						setTimeout(function() {
							that.actionsheetClose();
						}, 300);
						break;
					default:
						break;
				}
			},
			actionsheetClose() {
				let that = this;
				that.pageData.actionsheet.type = '';
				that.pageData.actionsheet.tips = '';
				that.pageData.actionsheet.itemList = [];
				that.pageData.actionsheet.param = {};
				that.pageData.actionsheet.show = false;
				that.$forceUpdate();
			},
			showModal(key, data) {
				let that = this;
				that.modalSite.status = !that.modalSite.status;
				that.modalSite.data = data;
				that.modalSite.key = key;
			},
			async clickModal(e) {
				let that = this;
				let index = e.index;
				that.modalSite.status = !that.modalSite.status;
				if (index == 1) {
					let param = {};
					switch (that.modalSite.key) {
						case "delete":
							param.id = that.modalSite.data.id;
							let delResponse = await that.tui.del(that.xhrUrl, param);
							that.tui.toast(delResponse.info, false, function() {
								switch (delResponse.status) {
									case 0:
										that.listData.page = 0;
										switch (that.get.tpl) {
											case 'address':
												that.tui.delCache('lastUppAddressData', function() {
													that.initList();
												});
												break;
											default:
												that.initList();
												break;
										}
										break;
									default:
										break;
								}
							}, 1500);
							break;
						default:
							console.log(that.modalSite);
							break;
					}
				}
			},
			async initList() {
				let that = this;
				if (that.listData.xhr.url === false) {
					that.listData.status = false;
					return;
				}
				if (that.listData.page == 0) {
					that.listData.data = [];
					that.listData.isMore = true;
					that.listData.status = true;
				}
				let param = {
					page: that.listData.page,
				};
				switch (that.get.tpl) {
					case 'invoiceTitle':
						that.listData.isMore = false;
						that.listData.xhr.status = false;
						that.listData.xhr.text = '没有更多啦 ... ...';
						break;
					default:
						param.length = that.tui.requestPageLength;
						break;
				}
				switch (that.get.tpl) {
					case 'wallet':
						param.field = that.get.key;
						if (that.pageData.tabs.data.length > 0) {
							switch (that.pageData.tabs.data[that.pageData.tabs.index].value) {
								case -1:
									break;
								default:
									param.type = that.pageData.tabs.data[that.pageData.tabs.index].value;
									break;
							}
						}
						break;
					case 'recharge':
						param.field = that.get.key;
						param.type = that.get.tpl;
						break;
					case 'team':
						if (typeof(that.get.parent_id) != 'undefined') {
							param.parent_id = that.get.parent_id;
						}
						break;
					default:
						break;
				}
				let response = await that.tui.get(that.listData.xhr.url, param);
				switch (response.status) {
					case 0:
						response = response.data;
						// 当前分页为0的时候 返回数据为0  暂无数据
						if (response.count == 0) {
							that.listData.isMore = false;
							that.listData.xhr.status = false;
							that.listData.xhr.text = '暂无数据... ...';
						} else {
							if (that.listData.page == 0) {
								if (response.data.length < param.length) {
									that.listData.status = false;
								}
							}
							that.listData.data = that.listData.data.concat(response.data);
							if (response.data.length < param.length) {
								that.listData.isMore = false;
								that.listData.xhr.status = false;
								if (response.data.length != 0) {
									that.listData.xhr.text = '没有更多啦 ... ...';
								}
							}
						}
						break;
					default:
						that.tui.toast(response.info, false, function() {
							that.listData.isMore = false;
							that.listData.xhr.status = false;
							that.listData.xhr.text = response.info;
						}, 1500);
						break;
				}
				that.$forceUpdate();
			},
			initNavigation(e) {
				let that = this;
				that.header.opacity = e.opacity;
				that.header.top = e.top;
			},
			changeNavigation(e) {
				let that = this;
				that.header.opacity = e.opacity;
			},
			back() {
				let that = this;
				that.tui.urlBack(1);
			},
		},
		// 页面滚动到底部的事件（不是scroll-view滚到底），常用于下拉下一页数据
		onReachBottom() {
			let that = this;
			if (that.listData.isMore == true) {
				that.listData.page++
				that.initList();
			}
		},
		// 监听页面隐藏
		onHide() {
			let that = this;
			switch (that.get.tpl) {
				case 'address':
				case 'invoiceTitle':
				case 'wxAppletMessageSubscriber':
					break;
				default:
					that.pageData.loading = false;
					break;
			}
		},
		// 监听页面卸载
		onUnload() {
			let that = this;
			that.actionsheetClose();
		},
		// 页面返回
		onBackPress() {
			let that = this;
			that.actionsheetClose();
		},
		// #ifdef MP-WEIXIN
		onShareAppMessage() {
			console.log('分享!')
		},
		// #endif
	}
</script>

<style scoped lang="scss">
	.tanxing {
		display: flex;
		align-items: center;
	}

	.touxiang {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		margin-right: 10rpx;
	}

	.tui-vip-box {
		max-width: 140rpx;
		padding: 4rpx 30rpx;
		background: linear-gradient(to right, #FDF1C8, #F8D15C);
		font-size: 16rpx;
		border-radius: 25rpx;
		color: #000000;
		text-align: center;
		line-height: 2;
	}

	.tui-explain {
		padding-top: 8rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		margin-top: 20rpx;
		
	}
	.explainName{
		font-size: 30rpx;
		color: #333333;
		// color: #fff;
	}
	.explainTime{
		font-size: 24rpx;
		color: #999999;
		
	}
	.explainPhone{
		font-size: 24rpx;
		color: #666666;
		margin-top: 30rpx;
		
	}
	.explainYeji{
		font-size: 24rpx;
		color: #666666;
	}
</style>